package com.pan;

import com.pan.entity.UMLInformation;
import com.pan.file.CreateFile;
import com.pan.file.impl.CreateXmlFile;
import com.pan.template.ParseTemplate;
import com.pan.template.impl.XmlParseTemplate;
import com.pan.uml.ParseUML;
import com.pan.uml.impl.PanParseUML;
import com.pan.utils.ScanTools;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class PanUML {

    public static void run(Class startClass,String fileName){
        ScanTools.INSTANCE.init(startClass);
        ParseUML parseUML = new PanParseUML();
        ParseTemplate parseTemplate = new XmlParseTemplate();
        CreateFile createFile = new CreateXmlFile();
        List<String> contentList = ScanTools.INSTANCE.getAllClass().stream().map(parseUML::toUML)
                .map(parseTemplate::toContent).collect(Collectors.toList());
        createFile.save(contentList,fileName);
        System.out.println("PanUmlTools Run Successfully!");
    }
    public static void run(Class startClass){
        run(startClass,"UML");
    }

    public static void main(String[] args) {
        PanUML.run(PanUML.class);
    }
}
